package wang.Seacher.seven.pipeline;

import java.time.LocalDateTime;

import com.geccocrawler.gecco.annotation.PipelineName;
import com.geccocrawler.gecco.pipeline.Pipeline;
import com.geccocrawler.gecco.request.HttpRequest;
import com.geccocrawler.gecco.scheduler.SchedulerContext;

import wang.Seacher.seven.bean.llllPic;
import wang.Seacher.seven.engine.DownPic;
import wang.Seacher.util.DateTimeStyle;
import wang.Seacher.util.JudgeUtil;

@PipelineName("getPicDetail")
public class GetPicDetail implements Pipeline<llllPic> {

	public void process(llllPic bean) {
		LocalDateTime startTime = LocalDateTime.now();
		HttpRequest request = bean.getRequest();
		if (JudgeUtil.isPresent(bean)) {
			if (JudgeUtil.isPresent(bean.getPictureVo()) && JudgeUtil.isPresent(bean.getPictureVo())) {
				DownPic.downPic(bean.getPictureVo(), request);
				
				if (JudgeUtil.isPresent(bean.getPictureVo().getHerf())) {
					getNextPage(request, bean.getPictureVo().getHerf());
				}
			}
		}
		System.out.println("\n!!!!!!!!!!!!!!!!!!finish ---一共用时" + DateTimeStyle.duration(startTime));

	}
	
	private void getNextPage(HttpRequest currRequest, String nextUrl) {
		// 下一页继续抓取
		System.out.println("nextUrl====>" + nextUrl);
		SchedulerContext.into(currRequest.subRequest(nextUrl));

	}

}
